package com.ld.hpfs.service.impl;


import java.util.ArrayList;
import java.util.HashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ld.hpfs.dao.MainMapper;
import com.ld.hpfs.service.MainService;
@Service
public class MainServiceImpl implements MainService{
	private static final Logger logger = LoggerFactory.getLogger(PlanServiceImpl.class);
	
	@Autowired
	private MainMapper mainMapper;
	
	@Override
	public ArrayList<HashMap<String,Object>> getMainList(HashMap<String,Object> param){
		int count = mainMapper.getMainListCount(param);
		if(count == 0){
			return null;
		}else{
			param.put("pageCount", count);
			return mainMapper.getMainList(param);
		}
	}
	
	@Override
	public String getCompanyId(String groupId){
		return mainMapper.getCompanyId(groupId);
	}
	@Override
	public int insertMain(HashMap<String,Object> param){
		try{
			mainMapper.insertMain(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public int copyMain(HashMap<String,Object> param){
		try{
			mainMapper.copyMain(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public HashMap<String,Object> checkGroupName(String groupName){
		return mainMapper.checkGroupName(groupName);
	}
	
	@Override
	public HashMap<String,Object> checkGroupId(String groupId){
		return mainMapper.checkGroupId(groupId);
	}
	@Override
	public int deleteMain(HashMap<String,Object> param){
		try{
			mainMapper.deleteMain(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public int updateMain(HashMap<String,Object> param){
		try{
			mainMapper.updateMain(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public int setQuoteMain(HashMap<String,Object> param){
		try{
			mainMapper.setQuoteMain(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public int checkVoucherFromCompany(HashMap<String,Object> param){
		try{
			int check = mainMapper.checkVoucherFromCompany(param);
			return check;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
}
